﻿(function () {
	var overrideContext = {};
	overrideContext.Templates = {};
	overrideContext.Templates.Fields = { 'DocIcon': { 'View': DocIconLinker } };

	SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideContext);
})();

function DocIconLinker(ctx) {
	var imageUrl = '/_layouts/15/images/';
	if (ctx.CurrentItem['HTML_x0020_File_x0020_Type.File_x0020_Type.mapico'])
		imageUrl += ctx.CurrentItem['HTML_x0020_File_x0020_Type.File_x0020_Type.mapico'];
	else if (1 == ctx.CurrentItem['FSObjType'])
		imageUrl += "folder.gif";
	else
		imageUrl += "icgen.gif";

	return '<a href="' + ctx.CurrentItem['FileRef'] + '"><img title="' + ctx.CurrentItem['FileLeafRef'] + '" border="0" alt="' + ctx.CurrentItem['FileLeafRef'] + '" src="' + imageUrl + '" width="16" height="16" DragId="1" /></a>';
}